<template>
  <template v-if="user">
    <van-cell title="当前用户" :value="user?.username" />
    <van-cell title="修改信息" is-link to="/user/update" />
    <van-cell title="我创建的队伍" is-link to="/user/team/create" />
    <van-cell title="我加入的队伍" is-link to="/user/team/join" />
  </template>
  <template v-else>
    <van-empty description="搜索为空" />
  </template>
</template>
  
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { useRouter } from "vue-router";
import { getCurrentUser } from "../services/user";

// const user = {
//   id: 1,
//   username: '鱼皮' ,
//   userAccount: 'yupi',
//   avatarUrl: '',
//   gender: '男',
//   phone: '123456789',
//   email: '1234567889@qq.com',
//   planetCode: '1234',
//   createTime: new Date(),
// }

const user = ref();

const router = useRouter();

onMounted(async () => {
  user.value = await getCurrentUser();
});

const toEdit = (editKey: string, editName: string, currentValue: string) => {
  router.push({
    path: "/user/edit",
    query: {
      editKey,
      currentValue,
      editName,
    },
  });
};
</script>
  
  <style>
</style>